<script setup>
import { ref } from 'vue'

const userStats = {
  totalProjects: 15,
  totalViews: 2300,
  totalLikes: 156,
  followers: 48
}

const recentActivities = [
  { 
    id: 1,
    type: 'create',
    title: '电子音乐视觉化',
    date: '2024-03-20',
    icon: '✨'
  },
  { 
    id: 2,
    type: 'like',
    title: '爵士乐动态效果',
    date: '2024-03-19',
    icon: '❤️'
  },
  { 
    id: 3,
    type: 'share',
    title: '古典音乐可视化',
    date: '2024-03-18',
    icon: '🔄'
  }
]

const popularProjects = [
  {
    id: 1,
    title: '电子音乐视觉化',
    views: 1200,
    likes: 156,
    thumbnail: 'https://placekitten.com/300/150'
  },
  {
    id: 2,
    title: '爵士乐动态效果',
    views: 850,
    likes: 92,
    thumbnail: 'https://placekitten.com/301/150'
  }
]

const achievements = [
  { 
    id: 1,
    title: '创作达人',
    description: '创建超过10个作品',
    icon: '🏆',
    progress: 100
  },
  { 
    id: 2,
    title: '人气之星',
    description: '获得超过100个赞',
    icon: '⭐',
    progress: 80
  },
  { 
    id: 3,
    title: '分享专家',
    description: '分享作品被观看1000次',
    icon: '🌟',
    progress: 60
  }
]

const chartData = {
  views: [120, 250, 180, 300, 280, 220, 400],
  likes: [20, 35, 25, 45, 40, 35, 50],
  dates: ['3-15', '3-16', '3-17', '3-18', '3-19', '3-20', '3-21']
}
</script>

<template>
  <div class="creator-center">
    <div class="dashboard-grid">
      <!-- 统计卡片区域 -->
      <div class="stats-section">
        <div class="stats-grid">
          <div class="stat-card">
            <div class="stat-icon">📊</div>
            <div class="stat-info">
              <div class="stat-value">{{ userStats.totalProjects }}</div>
              <div class="stat-label">作品数量</div>
            </div>
          </div>
          <div class="stat-card">
            <div class="stat-icon">👁️</div>
            <div class="stat-info">
              <div class="stat-value">{{ userStats.totalViews }}</div>
              <div class="stat-label">总播放量</div>
            </div>
          </div>
          <div class="stat-card">
            <div class="stat-icon">❤️</div>
            <div class="stat-info">
              <div class="stat-value">{{ userStats.totalLikes }}</div>
              <div class="stat-label">获赞数</div>
            </div>
          </div>
          <div class="stat-card">
            <div class="stat-icon">👥</div>
            <div class="stat-info">
              <div class="stat-value">{{ userStats.followers }}</div>
              <div class="stat-label">关注者</div>
            </div>
          </div>
        </div>
      </div>

      <!-- 数据趋势图 -->
      <div class="chart-section">
        <h3>数据趋势</h3>
        <div class="chart-container">
          <div class="chart-legend">
            <span class="legend-item">
              <span class="legend-color" style="background: var(--primary-color)"></span>
              播放量
            </span>
            <span class="legend-item">
              <span class="legend-color" style="background: var(--secondary-color)"></span>
              点赞数
            </span>
          </div>
          <div class="chart-grid">
            <div 
              v-for="(view, index) in chartData.views" 
              :key="index"
              class="chart-column"
            >
              <div class="chart-bar views" :style="{ height: view/4 + 'px' }"></div>
              <div class="chart-bar likes" :style="{ height: chartData.likes[index] + 'px' }"></div>
              <div class="chart-label">{{ chartData.dates[index] }}</div>
            </div>
          </div>
        </div>
      </div>

      <!-- 最近活动 -->
      <div class="activities-section">
        <h3>最近活动</h3>
        <div class="activity-list">
          <div 
            v-for="activity in recentActivities" 
            :key="activity.id"
            class="activity-item"
          >
            <span class="activity-icon">{{ activity.icon }}</span>
            <div class="activity-content">
              <div class="activity-title">{{ activity.title }}</div>
              <div class="activity-date">{{ activity.date }}</div>
            </div>
          </div>
        </div>
      </div>

      <!-- 热门作品 -->
      <div class="popular-section">
        <h3>热门作品</h3>
        <div class="popular-grid">
          <div 
            v-for="project in popularProjects"
            :key="project.id"
            class="popular-card"
          >
            <img :src="project.thumbnail" :alt="project.title">
            <div class="popular-info">
              <h4>{{ project.title }}</h4>
              <div class="popular-stats">
                <span>
                  <i>👁️</i> {{ project.views }}
                </span>
                <span>
                  <i>❤️</i> {{ project.likes }}
                </span>
              </div>
            </div>
          </div>
        </div>
      </div>

      <!-- 成就系统 -->
      <div class="achievements-section">
        <h3>我的成就</h3>
        <div class="achievements-grid">
          <div 
            v-for="achievement in achievements"
            :key="achievement.id"
            class="achievement-card"
          >
            <div class="achievement-icon">{{ achievement.icon }}</div>
            <div class="achievement-info">
              <h4>{{ achievement.title }}</h4>
              <p>{{ achievement.description }}</p>
              <div class="progress-bar">
                <div 
                  class="progress-fill"
                  :style="{ width: achievement.progress + '%' }"
                ></div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped>
.creator-center {
  padding: 1rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}

/* 统计卡片样式 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.stat-card {
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  font-size: 2rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-color);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* 图表样式 */
.chart-section {
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  grid-column: span 2;
}

.chart-legend {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.chart-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 200px;
  padding-top: 2rem;
}

.chart-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.chart-bar {
  width: 4px;
  border-radius: 2px;
  transition: height 0.3s;
}

.chart-bar.views {
  background: var(--primary-color);
}

.chart-bar.likes {
  background: var(--secondary-color);
}

.chart-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* 活动列表样式 */
.activities-section {
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--background-light);
  border-radius: 8px;
}

.activity-icon {
  font-size: 1.5rem;
}

.activity-date {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* 热门作品样式 */
.popular-section {
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.popular-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.popular-card {
  display: flex;
  gap: 1rem;
  background: var(--background-light);
  border-radius: 8px;
  overflow: hidden;
}

.popular-card img {
  width: 100px;
  height: 60px;
  object-fit: cover;
}

.popular-info {
  padding: 0.5rem;
  flex: 1;
}

.popular-stats {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* 成就系统样式 */
.achievements-section {
  background: white;
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.achievements-grid {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.achievement-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--background-light);
  border-radius: 8px;
}

.achievement-icon {
  font-size: 2rem;
}

.achievement-info {
  flex: 1;
}

.achievement-info p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.3s;
}

h3 {
  color: var(--text-primary);
  margin-bottom: 1rem;
}

h4 {
  color: var(--text-primary);
  margin: 0;
}
</style> 